package com.shengxing.lljl.payment.Alipay.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.shengxing.lljl.common.properties.AlipayProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class AlipayClientConfig {

    /**
     * 初始化sdk
     * @param alipayConfigurn
     * @return
     */
    @Bean
    public AlipayClient alipayClient(AlipayProperties alipayConfigurn) {
//        log.info("alipayConfig:{}",alipayConfigurn);
        return new DefaultAlipayClient(
                alipayConfigurn.getGatewayUrl(),
                alipayConfigurn.getAppId(),
                alipayConfigurn.getAppPrivateKey(),
                alipayConfigurn.getFormat(),
                alipayConfigurn.getCharset(),
                alipayConfigurn.getAlipayPublicKey(),
                alipayConfigurn.getSignType());
    }
}
